package ss.lianft.controller;

import org.apache.shiro.SecurityUtils;
import org.beetl.sql.core.engine.PageQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 获取request,response,session
 */
public class BaseController {
    protected Logger logger = LoggerFactory.getLogger(getClass());

    protected HttpServletRequest request;
    protected HttpServletResponse response;
    protected HttpSession session;

    @ModelAttribute
    public void init(HttpServletRequest request, HttpServletResponse response,HttpSession session){
        this.request = request;
        this.response = response;
        this.session = session;
    }

    public Map<String,Object> tableData(PageQuery query){
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("code",0);
        map.put("msg","加载成功");
        map.put("count",query.getTotalPage());
        map.put("data",query.getList());
        return map;
    }
}
